package org.geektimes.config.microprofile.source;

import org.eclipse.microprofile.config.spi.ConfigSource;

import java.util.Map;
import java.util.Set;

/**
 * @FileName: EnvPropertiesConfigSource
 * @Description: TODO
 * @Author: MaWenHao
 * @Created: 2021/3/17 - 下午10:33
 */
public class EnvPropertiesConfigSource implements ConfigSource {

    private Map<String, String> properties;

    public EnvPropertiesConfigSource() {
        this.properties = System.getenv();
    }

    @Override
    public Map<String, String> getProperties() {
        return properties;
    }

    @Override
    public Set<String> getPropertyNames() {
        return properties.keySet();
    }

    @Override
    public int getOrdinal() {
        return 500;
    }

    @Override
    public String getValue(String propertyName) {
        return properties.get(propertyName);
    }

    @Override
    public String getName() {
        return "ENV Properties";
    }
}
